package com.hdwx.weike.controllers;

import com.hdwx.weike.service.IUserService;
import com.hdwx.weike.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by hdwx on 2017/1/4.
 */
@WebServlet(urlPatterns = "/accountCheck.do")
public class AccountController extends BaseController{
    @Override
    public void todo(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        IUserService userService=new UserServiceImpl();
        String account = req.getParameter("account");
        boolean b = userService.searchAccount(account);
        if(b){//如果数据库中有该账户，返回0
            resp.getWriter().append("0");
        }else{//如果没有，可以注册，返回1
            resp.getWriter().append("1");
        }
    }
}
